<template>
	<view class="bank-card">
		<!-- <template v-if="state"> -->
			<view class="b-c-list" v-for="item in data" :key="item.id" @click="listClick(item.id)">
				<view class="c-l-text">
					<image class="c-l-t-img" :src="item.bankimage" ></image>
					<view class="c-l-t-text">
						<view class="c-l-t-text1">
							<text class="l-text">{{item.bankname || ''}}</text>
							<text class="l-text1" v-if="item.curruct">（默认提现卡）</text>
						</view>
					<text class="l-text">{{item.number || ''}}</text>
					</view>
				</view>
			</view>
		<view class="b-c-but">
			<button class="but" plain @click="addClick"><text class="but-text">+</text>添加银行卡</button>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zanwudingdan:`${getApp().globalData.imgScr}bj/zanwudingdan.png`,
				data:[],
				state:true,
			}
		},
		onShow() {
			this.getData()
		},
		methods:{
			/**
			 * 添加银行卡
			 */
			addClick() {
				uni.navigateTo({
					url: '/cleaningAdmin/my-wallet/bank-card/add-bank/add-bank'
				});
			},
			/**
			 * 点击银行卡时触发
			 * @param {Object} id 当前银行卡的id
			 */
			listClick(id) {
				uni.navigateTo({
					url: `/cleaningAdmin/my-wallet/bank-card/add-bank/add-bank?id=${id}`
				});
			},
			/**
			 * 获取数据
			 */
			async getData() {
				try{
					let res = await this.$http.post('/index/Cleanerindex/bank_list')
					this.data = res
					this.state = this.data.length
				}catch(e){
					this.state = false
					//TODO handle the exception
					uni.showToast({
						title: e.errMsg,
						icon:"none"
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.bank-card {
		width: 100%;
		box-sizing: border-box;
		padding: 22rpx 34rpx;
		.b-c-list {
			display: flex;
			justify-content: space-between;
			box-sizing: border-box;
			padding:32rpx;
			border-radius: 20rpx;
			background-color: #ffffff;
			margin-bottom: 34rpx;
			.c-l-img {
				margin-right: 28rpx;
				.l-img {
					width: 44rpx;
					height: 44rpx;
					border-radius: 22rpx;
					overflow: hidden;
				}
			}
			.c-l-text {
				flex: 1;
				display: flex;
				align-items: center;
				.c-l-t-img {
					width: 100rpx;
					height: 100rpx;
					margin-right: 20rpx;
				}
				.c-l-t-text {
					display: flex;
					flex-direction: column;
					.c-l-t-text1 {
						margin-bottom: 24rpx;
					}
					.l-text {
						font-size: 24rpx;
						font-weight: 600;
						color: #333333;
						margin-bottom: 16rpx;
					}
					.l-text1 {
						font-size: 18rpx;
						font-weight: 500;
						color: #B3B3B3;
					}
					.l-text2 {
						font-size: 34rpx;
						font-weight: 600;
						color: #333333;
						margin-right: 10rpx;
					}
				}
			}
		}
		.b-c-but {
			box-sizing: border-box;
			padding:0 32rpx;
			border-radius: 20rpx;
			background-color: #ffffff;
			.but {
				box-sizing: border-box;
				font-size: 28rpx;
				font-weight: 600;
				color: #333333;
				border-radius: 40rpx;
				line-height: 80rpx;
				border: 0;
				.but-text {
					font-size: 34rpx;
					font-weight: 600;
					color: #333333;
					margin-right: 10rpx;
				}
				.but-text1 {
					font-size: 28rpx;
					font-weight: 600;
					color: #333333;
					margin-right: 10rpx;
				}
			}
		}
	}
</style>
